<?php

namespace Action\Common;

use Lib\Action;
use Lib\Functions;

/**
 * Class Index
 * @package Action
 *
 * @property-read \Lib\Config $config
 */
class BaseLayout extends Action {
    public $breadcrumbs = [];
    public $templateData = [
        'header' => [
            'title' => ''
        ]
    ];

    /**
     * @param $key
     * @param $val
     * @param string $defVal
     * @param string $class
     * @return string
     */
    public function currentClass($key, $val, $defVal='', $class='actived') {
        $tab = $_GET[$key] ? $_GET[$key] : $defVal;

        if($tab == $val) {
            return $class;
        }

        return '';
    }

    public function addBreadcrumb($name, $url=null) {
        $this->breadcrumbs []= [
            'name' => $name,
            'url' => $url
        ];
    }
    
    public function outputHeader() {
        $this->view('common/header', false);
    }
    
    public function outputFooter() {
        $this->view('common/footer', false);
    }
}